﻿using Hang.Blog.DomainPlus.Consts;
using Hang.Blog.DomainPlus.EntityPlus;

using Microsoft.EntityFrameworkCore.Metadata.Builders;

using Volo.Abp.Auditing;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace Hang.Blog.DomainPlus.EntityframeworkExtension {
    public static class AbpEntityTypeBuilderExtensionsPlus {
        public static void ConfigureFullAuditedAggregateRootPlus<T>(this EntityTypeBuilder<T> b) where T : class, IUserName {
            b.ConfigureFullAuditedAggregateRoot();
            b.ConfigureUserName<T>();
        }

        public static void ConfigureFullAuditedPlus<T>(this EntityTypeBuilder<T> b) where T : class, IUserName, IFullAuditedObject {
            b.ConfigureFullAudited<T>();
            b.ConfigureUserName<T>();
        }



        public static void ConfigureUserName<T>(this EntityTypeBuilder<T> b) where T : class, IUserName {
            b.Property(x => x.CreateUserName).HasMaxLength(StringLengthConsts.Length500);
            b.Property(x => x.UpdateUserName).HasMaxLength(StringLengthConsts.Length500);
        }



    }
}
